﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MoonLight.LibCommon;
using MoonLight.LibDataOperator;
using PVAutoTest.LibCommon;
using PVAutoTest.BizSimulator;

namespace PVAutoTest.TestMngr
{
    public class TestCheckPoint
    {
        public TestCheckPoint()
        {
            m_cp_mask = (int)ProjectDefine.TCCheckPoints_e.CP_UNKNOWN;
            m_event = new TestData_Event();
            m_cp_func = new TestCheckPoint_Function();
            m_cp_db = new CheckPoint_DB();
        }

        ~TestCheckPoint()
        {
        }

        public void SetCheckPoints(int mask)
        {
            m_cp_mask = mask;
        }

        public int GetCheckPoints()
        {
            return m_cp_mask;
        }

        public void SetDBCheckPoints(CheckPoint_DB cp_db)
        {
            m_cp_db.table_componentevent.SetTable(cp_db.table_componentevent);
            m_cp_db.table_componentstate.SetTable(cp_db.table_componentstate);
            m_cp_db.table_dayfail.SetTable(cp_db.table_dayfail);
            m_cp_db.table_devicefail.SetTable(cp_db.table_devicefail);

            m_cp_db.table_event.SetTable(cp_db.table_event);
            m_cp_db.table_eventfrequency.SetTable(cp_db.table_eventfrequency);
            m_cp_db.table_groupevent.SetTable(cp_db.table_groupevent);
            m_cp_db.table_groupstate.SetTable(cp_db.table_groupstate);

            m_cp_db.table_monthfail.SetTable(cp_db.table_monthfail);
            m_cp_db.table_openevent.SetTable(cp_db.table_openevent);
            m_cp_db.table_pmresult.SetTable(cp_db.table_pmresult);
            m_cp_db.table_state.SetTable(cp_db.table_state);
        }

        public CheckPoint_DB GetDBCheckPoints()
        {
            return m_cp_db;
        }

        public void SetExpectedResult(TestData td)
        {
            m_event = (TestData_Event)td;
        }

        public ProjectDefine.TCResult_e CheckPointDB(ref string err_info, ref string expect_value, ref string actual_value)
        {
            ProjectDefine.TCResult_e result = ProjectDefine.TCResult_e.TC_UNKNOWN;

            #region Table->Event
            if (m_cp_db.table_event.MessageNo)
            {
                result = m_cp_func.check_point_db_tb_event_messageno(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }

            if (m_cp_db.table_event.EventNo)
            {
                result = m_cp_func.check_point_db_tb_event_eventno(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }

            if (m_cp_db.table_event.OrgMessage)
            {
                result = m_cp_func.check_point_db_tb_event_orgmessage(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }

            if (m_cp_db.table_event.DeviceState)
            {
                result = m_cp_func.check_point_db_tb_event_devicestate(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }
            #endregion

            #region Table->ComponentEvent
            if (m_cp_db.table_componentevent.ComponentId)
            {
                result = m_cp_func.check_point_db_tb_componentevent_componentid(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }

            if (m_cp_db.table_componentevent.CompState)
            {
                result = m_cp_func.check_point_db_tb_componentevent_componentstate(m_event, ref err_info, ref expect_value, ref actual_value);
                if (result != ProjectDefine.TCResult_e.TC_UNKNOWN)
                    return result;
            }
            #endregion

            #region Table->DeviceFail
            if (m_cp_db.table_devicefail.ComponentId)
            {
                
            }

            if (m_cp_db.table_devicefail.CompFailCount)
            {
                
            }

            if (m_cp_db.table_devicefail.Started)
            {
                
            }

            if (m_cp_db.table_devicefail.Ended)
            {
                
            }

            if (m_cp_db.table_devicefail.EventNo)
            {
                
            }

            if (m_cp_db.table_devicefail.State)
            {
                
            }

            if (m_cp_db.table_devicefail.CompState)
            {
                
            }

            if (m_cp_db.table_devicefail.StateBit)
            {
                
            }

            if (m_cp_db.table_devicefail.EndEventNo)
            {
                
            }
            #endregion

            #region Table->DayFail
            if (m_cp_db.table_dayfail.Started)
            {
                
            }

            if (m_cp_db.table_dayfail.ComponentId)
            {
                
            }

            if (m_cp_db.table_dayfail.Ended)
            {
                
            }

            if (m_cp_db.table_dayfail.EventNo)
            {
                
            }

            if (m_cp_db.table_dayfail.State)
            {
                
            }

            if (m_cp_db.table_dayfail.CompState)
            {
                
            }

            if (m_cp_db.table_dayfail.StateBit)
            {
                
            }
            #endregion

            #region Table->MonthFail
            if (m_cp_db.table_monthfail.ComponentId)
            {

            }

            if (m_cp_db.table_monthfail.TotalTime)
            {

            }
            #endregion

            #region Table->State
            if (m_cp_db.table_state.DeviceState)
            {

            }

            if (m_cp_db.table_state.EventCount)
            {

            }

            if (m_cp_db.table_state.ExtraEventCount)
            {

            }
            #endregion

            #region Table->EventFrequency
            if (m_cp_db.table_eventfrequency.Count)
            { 
                
            }
            #endregion

            #region Table->OpenEvent
            if(m_cp_db.table_openevent.ComponentId)
            {
    
            }

            if(m_cp_db.table_openevent.BitNo)
            {
    
            }

            if(m_cp_db.table_openevent.EventNo)
            {
    
            }

            if(m_cp_db.table_openevent.CompState)
            {
    
            }

            if (m_cp_db.table_openevent.MessageNo)
            {

            }

            if (m_cp_db.table_openevent.DeviceState)
            {

            }

            if (m_cp_db.table_openevent.OrgMessage)
            {

            }
            #endregion

            #region Table->GroupState
            if (m_cp_db.table_groupstate.State)
            {

            }

            if (m_cp_db.table_groupstate.EventCount)
            {

            }
            #endregion

            #region Table->ComponentState
            if (m_cp_db.table_componentstate.CompState)
            {

            }
            #endregion

            #region Table->GroupEvent
            if (m_cp_db.table_groupevent.EventNo)
            {

            }

            if (m_cp_db.table_groupevent.OrgMessage)
            {

            }

            if (m_cp_db.table_groupevent.GroupState)
            {

            }
            #endregion

            #region Table->PmResult
            if (m_cp_db.table_pmresult.PmId)
            {

            }

            if (m_cp_db.table_pmresult.Step)
            {

            }

            if (m_cp_db.table_pmresult.TriggerType)
            {

            }

            if (m_cp_db.table_pmresult.Result)
            {

            }

            if (m_cp_db.table_pmresult.State)
            {

            }
            #endregion

            return ProjectDefine.TCResult_e.TC_PASSED;
        }

        public ProjectDefine.TCResult_e CheckPointTrace()
        {
            return m_cp_func.check_point_trace();
        }

        public ProjectDefine.TCResult_e CheckPointLog()
        {
            return m_cp_func.check_point_log();
        }

        private int m_cp_mask;
        private TestData_Event m_event;
        private TestCheckPoint_Function m_cp_func;
        private CheckPoint_DB m_cp_db;
    }

    public class TestCheckPoint_Function
    { 
        public TestCheckPoint_Function()
        {
        }

        ~TestCheckPoint_Function()
        {
        }

        #region DB Check->Event Table
        public ProjectDefine.TCResult_e check_point_db_tb_event_messageno(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check messageno
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select top 1 messageno from event where deviceid = @deviceid order by eventcount desc";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                Logger.WriteLog("select messageno fail");
                err_info = "Table:Event->select messageno fail";
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.msg_no)
            {
                err_info = "Table:Event->messageno incorrect";
                expect_val = expect_result.msg_no;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("msgno is " + dt.Rows[0][0]);
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }

        public ProjectDefine.TCResult_e check_point_db_tb_event_eventno(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check eventno
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select top 1 eventno from event where deviceid = @deviceid order by eventcount desc";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:Event->select eventno fail";
                Logger.WriteLog("select eventno fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.event_no)
            {
                err_info = "Table:Event->eventno incorrect";
                expect_val = expect_result.event_no;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("eventno is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }

        public ProjectDefine.TCResult_e check_point_db_tb_event_orgmessage(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check orgmessage string
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select top 1 orgmessage from event where deviceid = @deviceid order by eventcount desc";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:Event->select orgmessage fail";
                Logger.WriteLog("select orgmessage fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.msg_str)
            {
                string temp = dt.Rows[0][0].ToString();
                err_info = "Table:Event->orgmessage incorrect";
                expect_val = expect_result.msg_str;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("msg_str is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }

        public ProjectDefine.TCResult_e check_point_db_tb_event_devicestate(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check device state
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select devicestate from event where deviceid = @deviceid and eventcount = (select MAX(eventcount)-1 from event where deviceid = @deviceid)";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:Event->select org devicestate fail";
                Logger.WriteLog("select org devicestate fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0)
            {
                err_info = "Table:Event->no org devicestate find";
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            string lstate = dt.Rows[0][0].ToString();
            para_list.Clear();
            sql = "select devicestate from event where deviceid = @deviceid and eventcount = (select MAX(eventcount) from event where deviceid = @deviceid)";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:Event->select last devicestate fail";
                Logger.WriteLog("select last devicestate fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0)
            {
                err_info = "Table:Event->no last devicestate find";
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            string orgstate = dt.Rows[0][0].ToString();
            Logger.WriteLog("lstate is " + lstate + ",orgstate is " + orgstate);
            if (Convert.ToInt32(lstate) != (Convert.ToInt32(orgstate) | Convert.ToInt32(expect_result.set_state)))
            {
                err_info = "Table:Event->last state incorrect";
                expect_val = (Convert.ToInt32(orgstate) | Convert.ToInt32(expect_result.set_state)).ToString();
                actual_val = lstate;
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("msg_str is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }
        #endregion

        #region DB Check->ComponentEvent Table
        public ProjectDefine.TCResult_e check_point_db_tb_componentevent_componentid(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check componentid 
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select componentid from componentevent where deviceid = @deviceid and eventcount = (select MAX(eventcount) from event where deviceid = @deviceid)";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:componentevent->select componentid fail";
                Logger.WriteLog("select componentid fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.component_id)
            {
                err_info = "Table:componentevent->componentid incorrect";
                expect_val = expect_result.component_id;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("component_id is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }

        public ProjectDefine.TCResult_e check_point_db_tb_componentevent_componentstate(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check component state 
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select compstate from componentevent where deviceid = @deviceid and eventcount = (select MAX(eventcount) from event where deviceid = @deviceid)";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:componentevent->select compstate fail";
                Logger.WriteLog("select compstate in ComponentEvent fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.component_state)
            {
                err_info = "Table:componentevent->compstate incorrect";
                expect_val = expect_result.component_state;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("component_state is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }
        #endregion 

        #region DB Check->ComponentState Table
        public ProjectDefine.TCResult_e check_point_db_tb_componentstate_componentid(TestData_Event expect_result, ref string err_info, ref string expect_val, ref string actual_val)
        {
            DBOperator db_op = new DBOperator();
            if (db_op.ConnectDB(ProjectDefine.ConnStr) < 0)
            {
                Logger.WriteLog("connect to db fail");
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            //check component state 
            List<SqlParameter> para_list = new List<SqlParameter>();
            string sql = "select c.compstate from event a inner join componentevent b " +
                "on a.deviceid = b.deviceid and a.eventcount = b.eventcount " +
                "inner join componentstate c " +
                "on b.deviceid = c.deviceid and b.componentid = c.componentid " +
                "inner join (select MAX(eventcount) eventcount from event where deviceid = @deviceid and eventno = @eventno) d " +
                "on a.eventcount = d.eventcount " +
                "where a.deviceid = @deviceid and eventno = @eventno";
            para_list.Add(new SqlParameter("@deviceid", expect_result.dev_id));
            para_list.Add(new SqlParameter("@eventno", expect_result.event_no));
            DataTable dt = new DataTable();
            if (db_op.ExecuteDataTable(sql, para_list, false, ref dt) < 0)
            {
                err_info = "Table:componentstate->select compstate fail";
                Logger.WriteLog("select compstate in ComponentState fail");
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_ERROR;
            }
            if (dt.Rows.Count <= 0 || dt.Rows[0][0].ToString() != expect_result.component_state)
            {
                err_info = "Table:componentstate->compstate incorrect";
                expect_val = expect_result.component_state;
                actual_val = dt.Rows.Count <= 0 ? "no value" : dt.Rows[0][0].ToString();
                db_op.CloseDB();
                return ProjectDefine.TCResult_e.TC_FAILED;
            }
            Logger.WriteLog("component_state is " + dt.Rows[0][0].ToString());
            return ProjectDefine.TCResult_e.TC_UNKNOWN;
        }
        #endregion 

        public ProjectDefine.TCResult_e check_point_trace()
        {
            return ProjectDefine.TCResult_e.TC_PASSED;
        }

        public ProjectDefine.TCResult_e check_point_log()
        {
            return ProjectDefine.TCResult_e.TC_PASSED;
        }
    }

    public class CheckPoint_DB
    {
        public CheckPoint_DB()
        {
            table_event = new CheckPoint_Table_Event();
            table_componentevent = new CheckPoint_Table_ComponentEvent();
            table_devicefail = new CheckPoint_Table_DeviceFail();
            table_dayfail = new CheckPoint_Table_DayFail();

            table_monthfail = new CheckPoint_Table_MonthFail();
            table_state = new CheckPoint_Table_State();
            table_eventfrequency = new CheckPoint_Table_EventFrequency();
            table_openevent = new CheckPoint_Table_OpenEvent();

            table_groupstate = new CheckPoint_Table_GroupState();
            table_componentstate = new CheckPoint_Table_ComponentState();
            table_groupevent = new CheckPoint_Table_GroupEvent();
            table_pmresult = new CheckPoint_Table_PmResult();
        }

        public CheckPoint_Table_Event table_event;
        public CheckPoint_Table_ComponentEvent table_componentevent;
        public CheckPoint_Table_DeviceFail table_devicefail;
        public CheckPoint_Table_DayFail table_dayfail;

        public CheckPoint_Table_MonthFail table_monthfail;
        public CheckPoint_Table_State table_state;
        public CheckPoint_Table_EventFrequency table_eventfrequency;
        public CheckPoint_Table_OpenEvent table_openevent;

        public CheckPoint_Table_GroupState table_groupstate;
        public CheckPoint_Table_ComponentState table_componentstate;
        public CheckPoint_Table_GroupEvent table_groupevent;
        public CheckPoint_Table_PmResult table_pmresult;
    }

    public class CheckPoint_Table_Event
    {
        public void SetTable(CheckPoint_Table_Event tb)
        {
            MessageNo = tb.MessageNo;
            EventNo = tb.EventNo;
            OrgMessage = tb.OrgMessage;
            DeviceState = tb.DeviceState;
        }

        public bool MessageNo = false;
        public bool EventNo = false;
        public bool OrgMessage = false;
        public bool DeviceState = false;
    }

    public class CheckPoint_Table_ComponentEvent
    {
        public void SetTable(CheckPoint_Table_ComponentEvent tb)
        {
            ComponentId = tb.ComponentId;
            CompState = tb.CompState;
        }

        public bool ComponentId = false;
        public bool CompState = false;
    }

    public class CheckPoint_Table_DeviceFail
    {
        public void SetTable(CheckPoint_Table_DeviceFail tb)
        {
            ComponentId = tb.ComponentId;
            CompFailCount = tb.CompFailCount;
            Started = tb.Started;
            Ended = tb.Ended;
            EventNo = tb.EventNo;
            State = tb.State;
            CompState = tb.CompState;
            StateBit = tb.StateBit;
            EndEventNo = tb.EndEventNo;
        }

        public bool ComponentId = false;
        public bool CompFailCount = false;
        public bool Started = false;
        public bool Ended = false;
        public bool EventNo = false;
        public bool State = false;
        public bool CompState = false;
        public bool StateBit = false;
        public bool EndEventNo = false;
    }

    public class CheckPoint_Table_DayFail
    {
        public void SetTable(CheckPoint_Table_DayFail tb)
        {
            Started = tb.Started;
            ComponentId = tb.ComponentId;
            Ended = tb.Ended;
            EventNo = tb.EventNo;
            State = tb.State;
            CompState = tb.CompState;
            StateBit = tb.StateBit;
        }

        public bool Started = false;
        public bool ComponentId = false;
        public bool Ended = false;
        public bool EventNo = false;
        public bool State = false;
        public bool CompState = false;
        public bool StateBit = false;
    }

    public class CheckPoint_Table_MonthFail
    {
        public void SetTable(CheckPoint_Table_MonthFail tb)
        {
            ComponentId = tb.ComponentId;
            TotalTime = tb.TotalTime;
        }

        public bool ComponentId = false;
        public bool TotalTime = false;
    }

    public class CheckPoint_Table_State
    {
        public void SetTable(CheckPoint_Table_State tb)
        {
            DeviceState = tb.DeviceState;
            EventCount = tb.EventCount;
            ExtraEventCount = tb.ExtraEventCount;
        }

        public bool DeviceState = false;
        public bool EventCount = false;
        public bool ExtraEventCount = false;
    }

    public class CheckPoint_Table_EventFrequency
    {
        public void SetTable(CheckPoint_Table_EventFrequency tb)
        {
            Count = tb.Count;
        }

        public bool Count = false;
    }

    public class CheckPoint_Table_OpenEvent
    {
        public void SetTable(CheckPoint_Table_OpenEvent tb)
        {
            ComponentId = tb.ComponentId;
            BitNo = tb.BitNo;
            EventNo = tb.EventNo;
            CompState = tb.CompState;
            MessageNo = tb.MessageNo;
            DeviceState = tb.DeviceState;
            OrgMessage = tb.OrgMessage;
        }

        public bool ComponentId = false;
        public bool BitNo = false;
        public bool EventNo = false;
        public bool CompState = false;
        public bool MessageNo = false;
        public bool DeviceState = false;
        public bool OrgMessage = false;
    }

    public class CheckPoint_Table_GroupState
    {
        public void SetTable(CheckPoint_Table_GroupState tb)
        {
            State = tb.State;
            EventCount = tb.EventCount;
        }

        public bool State = false;
        public bool EventCount = false;
    }

    public class CheckPoint_Table_ComponentState
    {
        public void SetTable(CheckPoint_Table_ComponentState tb)
        {
            CompState = tb.CompState;
        }

        public bool CompState = false;
    }

    public class CheckPoint_Table_GroupEvent
    {
        public void SetTable(CheckPoint_Table_GroupEvent tb)
        {
            EventNo = tb.EventNo;
            OrgMessage = tb.OrgMessage;
            GroupState = tb.GroupState;
        }

        public bool EventNo = false;
        public bool OrgMessage = false;
        public bool GroupState = false;
    }

    public class CheckPoint_Table_PmResult
    {
        public void SetTable(CheckPoint_Table_PmResult tb)
        {
            PmId = tb.PmId;
            Step = tb.Step;
            TriggerType = tb.TriggerType;
            Result = tb.Result;
            State = tb.State;
        }

        public bool PmId = false;
        public bool Step = false;
        public bool TriggerType = false;
        public bool Result = false;
        public bool State = false;
    }
}
